<template>
    <div>
        <Breadcrumb />

        <el-row class="title">
            <el-col :span="8"
                ><div>
                    <span>名字：</span
                    ><input type="text" placeholder="请输入" /></div
            ></el-col>
            <el-col :span="8"
                ><div>
                    <span>电话号码：</span
                    ><input type="text" placeholder="请输入" /></div
            ></el-col>
            <el-col :span="8">
                <el-button type="warning" size="mini">查询</el-button>
                <el-button type="warning" size="mini" @click="addAdmin"
                    >新增</el-button
                >
            </el-col>
        </el-row>
        <el-table :data="rows" height="360px" border style="width: 100%">
            <el-table-column label="账号" prop="account"> </el-table-column>
            <el-table-column label="真实名字" prop="realname">
            </el-table-column>
            <el-table-column label="电话号码" prop="telephone">
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button
                        size="mini"
                        type="danger"
                        @click="handleDelete(scope.$index, scope.row)"
                        >删除</el-button
                    >
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions, mapState } = createNamespacedHelpers("admins");
import Breadcrumb from "../../commponents/common/Breadcrumb.vue";
export default {
    data() {
        return {
            value: "",
        };
    },
    components: { Breadcrumb },
    methods: {
        ...mapActions(["getDataAsync", "delDataAsync"]),
        addAdmin() {
            this.$router.push("/home/usersAdd");
        },
        async handleDelete(index, row) {
            const data = await this.delDataAsync({ _id: row._id });
            if (data.code == 200) {
                this.open2();
                this.getDataAsync();
            }
        },
        open2() {
            this.$message({
                message: "删除成功",
                type: "success",
            });
        },
    },
    created() {
        this.getDataAsync();
    },
    computed: {
        ...mapState(["rows"]),
    },
};
</script>

<style scoped lang="scss">
.title {
    text-align: left;
    height: 60px;
    line-height: 60px;
    background: #fff;
    margin: 10px;
    border-radius: 10px;
    input {
        width: 150px;
    }
    .el-col {
        padding-left: 20px;
        &:last-child {
            text-align: center;
        }
    }
    button:last-child {
        border: 0;
        background-color: rgb(253, 160, 133);
    }
}
.has-gutter tr {
    background-color: rgb(253, 160, 133);
}
</style>